﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using NuPattern.Diagnostics;

namespace MVCAppToolkit.Automation.TypeConverters
{
    /// <summary>
    /// A custom type converter for returning a list of System.String values.
    /// </summary>
    [DisplayName("Field Data Types")]
    [Category("MVC Applications")]
    [Description("Returns a list of Field data types.")]
    [CLSCompliant(false)]
    public class FieldDataTypeConverter : StringConverter
    {
        private static readonly ITracer tracer = Tracer.Get<FieldDataTypeConverter>();

        /// <summary>
        /// Determines whether this converter supports standard values.
        /// </summary>
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        /// <summary>
        /// Determines whether this converter only allows selection of items returned by <see cref="GetStandardValues"/>.
        /// </summary>
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            return true;
        }

        /// <summary>
        /// Returns the list of string values for the enumeration
        /// </summary>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            var items = new List<string>();

            // Fixed list of field data types
            items.Add(typeof(string).FullName);
            items.Add(typeof(int).FullName);
            items.Add(typeof(DateTime).FullName);
            items.Add(typeof(Decimal).FullName);

            return new StandardValuesCollection(items);
        }
    }
}
